package gui;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import logic.objects.Problem;

public class SetupPanel extends JPanel {
	private CoordinateTable table;

	public SetupPanel(Problem problem) {
		// GraphicVariables.MAX_HEIGHT_Table);
		table = new CoordinateTable(problem);

		table.getColumnModel().getColumn(0)
				.setMaxWidth(GraphicVariables.MAX_WIDTH_Table / 2);

		table.getColumnModel().getColumn(1)
				.setMaxWidth(GraphicVariables.MAX_WIDTH_Table / 2);
		JScrollPane pane=new JScrollPane(table);
		pane.setPreferredSize(new Dimension(GraphicVariables.MAX_WIDTH_Table, 400));
		add(pane);
	}

	public void removeSelected() {

		table.removeAll(table.getSelectedRows());

	}

	public void applyChanges() {
		table.applyChanges();
	}
	public void add(int x, int y){
		table.add(x,y);
	}
	public boolean check(int x, int y){
		for (int i=0;i<table.getData().length;i++)
		if ((x+"").equals(table.getData()[i][0])  && (y+"").equals(table.getData()[i][1])){
			return false;
		}
		return true;
	}
}
